import request from "@/assets/js/request";
import util from "@/assets/js/public";
import { getToken } from '@/assets/js/auth';
import Vue from "vue";

//获取用户信息
export function getUserdata(params){
    console.log('获取用户信息时的名字是：'+params.userName);
    return request(
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/getCurrentUser$sso',
            contentType: 'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "noAction": "1",
                "versionName":"2.7.92",
                    "kv":{
                        "versionName":"2.7.92",
                        "versionCode":2079200,
                        "appcode":"djfupt",
                        "currentUserCode":util.encrypt(params.userName),
                    }
            }
        }
    )
}



//获取待办列表
export function getMytodo(params){
    console.log(params.userName+'AAAA'+getToken()+'URL:'+process.env.VUE_MOBILE_URL);
    return request(
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/queryActBusinessStatus$api$myTaskToDo?source=MOBILE&page='
            +params.page+"&rows"+params.rows+"&size=10",
            contentType: 'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "currentUserCode":util.encrypt(params.userName),
                "versionName":"2.7.92",
                "kv":{
                    "source":'MOBILE',
                    "page":params.page,
                    "rows":params.rows,
                    "size":params.size,
                    "title":params.searchTitle,
                    "workCode":params.searchCode,
                    "currentUserCode":util.encrypt(params.userName),
                },
               
            }
        }
    )
}

//获取已办列表
export function getMydid(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/queryActBusinessStatus$api$queryMyJoin?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"djfupt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "kv":{
                "source":'MOBILE',
                "page":params.page,
                "rows":params.rows,
                "size":params.size,
                "title":params.searchTitle,
                "workCode":params.searchCode,
                "currentUserCode":util.encrypt(params.userName),
            },
            
        }
    })
}

//获取政策宣讲工单详情
export function getZcxjDetail(params){
    console.log('CCCCCCCCCC'+params.processInstId)
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usPolicyInfo$api$getFormDetail?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"djfupt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
                "kv":{
                    "source":'MOBILE',
                    "currentUserCode":util.encrypt(params.userName),
                    "processInstId":params.processInstId,
                    "workFlag":params.workFlag,
                    "location":params.location,
                    "pmInsId":params.pmInsId,
                }
        }
    })
}

//获取政策宣讲台账工单详情
export function getZcxjTaizhangDetail(params){
    console.log('CCCCCCCCCC'+params.taizhangId)
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usPolicyInfo$api$findPolicyDeatir?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"djfupt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
                "kv":{
                    "source":'MOBILE',
                    "currentUserCode":util.encrypt(params.userName),
                    "id":params.taizhangId,
                 
                }
        }
    })
}

//获取政策宣讲历史审批意见
export function getZcxjOpinionDetail(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/queryOpinionHistory$api$getWfOptMags?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"djfupt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
                "kv":{
                    "source":'MOBILE',
                    "currentUserCode":util.encrypt(params.userName),
                    "processInstId":params.processInstId,
                }
        }
    })
}

//获取政策宣讲的表格数据
export function getZcxjFromListDetail(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usPantchDetail$api$mattersList?source=MOBILE&'+
        '&page=1&rows=20&size=20',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"djfupt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
                "kv":{
                    "source":'MOBILE',
                    "currentUserCode":util.encrypt(params.userName),
                    "webId":params.webId,
                    "pmInsId":params.pmInsId,
                    "page":"1",
                    "rows":"20",
                    "size":"20",
                }
        }
    })
}

//获取政策宣讲工单的表格详情
export function getZcxjFromDetail(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usPantchDetail$api$checkUsPantchDetail?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"djfupt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
                "kv":{
                    "source":'MOBILE',
                    "currentUserCode":util.encrypt(params.userName),
                    "id":params.fileId,
                }
        }
    })
}

//删除表单数据
export function deleteFromdata(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usPantchDetail$api$deleteUsPantchDetail?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"djfupt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
                "kv":{
                    "source":'MOBILE',
                    "currentUserCode":util.encrypt(params.userName),
                    "id":params.fileId,
                }
        }
    })
}
export function uploadProcessFiles(fd,params){
    console.log('CCCCCCCCCC'+process.env.VUE_APP_UPFILE)
    return request({
        url:process.env.VUE_APP_URL+'/action/openapi/bps/common/uploadFile?pmInsType=A&pmInsTypePart=1&appcode=djfupt&currentUserCode='
        +util.encrypt(params.userName)+'&access_token='+getToken(),
        contentType:'multipart/form-data',
        data:fd,
        catch:true
    })
}

// export function uploadProcessFiles(fileData,params){
//     return request({
//         url:process.env.VUE_APP_URL+'uploadFile?pmInsType=A&pmInsTypePart=1&appcode=djfupt&currentUserCode='
//         +util.encrypt(params.userName)+'&access_token='+getToken(),
//         contentType:'multipart/form-data',
//         data:{
//             "access_token":getToken(),
//             "appCode":"djfupt",
//             "currentUserCode":util.encrypt(params.userName),
//             "versionName":"2.7.92",
//             "pmInsType":'A',
//             "source":'MOBILE',
//             "pmInsTypePart":'1',
//              "file":fileData   
//         },
//         catch:true
//     })
// }
// export function uploadProcessFilesSYS(fd) {
//     // let url=util.toUrl(,data || {});
//     return request({
//       // url:url,
//       url: process.env.VUE_APP_URL + 'uploadFile',
//       contentType: 'multipart/form-data',
//       data: fd,
//       catch: true
//     })
//   }
export function uploadProcessFilesSYS(fileData,params){
    let url = process.env.VUE_APP_URL+'/action/openapi/bps/common/uploadFile?';
    return request({
        url,
        contentType:'multipart/form-data',
        data:{
            "access_token":getToken(),
            "appcode":"djfupt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "pmInsType":"A",
            "pmInsTypePart":"1",
            "jsonName":'appDecision',
            fileData
        }
    })
}

//保存政策宣讲工单的表格
export function saveZcxjFromDetail(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usPantchDetail$api$insertUsPantchDetail?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"djfupt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
            },
            "jsonName":'appDecision',
            "appDecision":params.fromdetaildata
        }
    })
}

  //修改政策宣讲工单的表格
  export function changeZcxjFromDetail(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usPantchDetail$api$updateUsPantchDetail?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"djfupt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
            },
            "jsonName":'appDecision',
            "appDecision":params.fromdetaildata
        }
    })
}

//获取政策宣讲决策项 
export function zcxjgetDecisions(params){
    console.log("name:"+params.userName+'工单类型是：'+params.idcode.processType)
    var usrls='usPolicyInfo$api$getDecisions';
    if(params.idcode.processType == 'A'){
        usrls='usCaseInfo$api$getDecisions';
    }else if(params.idcode.processType == 'B'){
        usrls='usProblemInfo$api$getDecisions';
    }else if(params.idcode.processType == 'C'){
        usrls='usPolicyInfo$api$getDecisions';
    }
    return request(
        {
            url:process.env.VUE_APP_URL +'/action/openapi/bps/common/transmit/'+ usrls+'?source=MOBILE',
            contentType:'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "currentUserCode":util.encrypt(params.userName),
                "versionName":"2.7.92",
                "source":'MOBILE',
                "kv":{
                    "currentUserCode":util.encrypt(params.userName),
                    "source":'MOBILE',
                    "processType":params.idcode.processType,
                    "location":params.idcode.location,
                    "processInstId":params.idcode.processInstId,
                    "processDefName":params.idcode.processDefName,
                    "questionMode":params.formData.questionMode
                }
            }
        }
    )
}
//获取政策宣讲候选人
export function zcxjgetNextUser(params){
    console.log("name:"+params.userName+'工单类型是：'+params.idcode.processType)
    var usrls='usPolicyInfo$api$getOrgAndUser';
    if(params.idcode.processType == 'A'){
        usrls='usCaseInfo$api$getOrgAndUser';
    }else if(params.idcode.processType == 'B'){
        usrls='usProblemInfo$api$getOrgAndUser';
    }else if(params.idcode.processType == 'C'){
        usrls='usPolicyInfo$api$getOrgAndUser';
    }
    return request(
        {
            url:process.env.VUE_APP_URL +'/action/openapi/bps/common/transmit/'+ usrls+'?source=MOBILE',
            contentType:'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "currentUserCode":util.encrypt(params.userName),
                "versionName":"2.7.92",
                "source":'MOBILE',
                "kv":{
                    "currentUserCode":util.encrypt(params.userName),
                    "source":'MOBILE',
                    "location":params.idcode.location,
                    "processInstId":params.idcode.processInstId,
                    "processType":params.idcode.processType
                },
                "jsonName":'appDecision',
                "appDecision":params.decisiondata
            }
        }
    )
}
//政策宣讲提交流转
export function zcxjGotoSubmitProcess(params){
    console.log("name:"+params.userName+'工单类型是：'+params.idcode.processType)
    var usrls='usPolicyInfo$api$startSubmitProcess';
    if(params.idcode.processType == 'A'){
        usrls='usCaseInfo$api$startSubmitProcess';
    }else if(params.idcode.processType == 'B'){
        usrls='usProblemInfo$api$startSubmitProcess';
    }else if(params.idcode.processType == 'C'){
        usrls='usPolicyInfo$api$startSubmitProcess';
    }
    return request(
        {
            url:process.env.VUE_APP_URL +'/action/openapi/bps/common/transmit/'+ usrls+'?source=MOBILE',
            contentType: 'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "currentUserCode":util.encrypt(params.userName),
                "versionName":"2.7.92",
                    "kv":{
                        "source":'MOBILE',
                        "currentUserCode":util.encrypt(params.userName),
                        "workItemId":params.idcode.workItemId,    
                        "outcome":params.outcome,    
                        "processInstId":params.idcode.processInstId,  
                        "location":params.idcode.location,  
                        "outcomeName":params.outcomeName,  
                    },
                "jsonName":'appDecision',
                "appDecision":params.flowParam    
            }
        }
    )
}
//获取政策宣讲台账列表
export function getzcxjtaizhang(params){
    console.log(params.userName+'AAAA'+getToken());
    return request(
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usPolicyInfo$api$findPolicyDeatilLeder?source=MOBILE&page='
            +params.page+"&rows="+params.rows+"&size=10",
            contentType: 'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "currentUserCode":util.encrypt(params.userName),
                "versionName":"2.7.92",
                    "kv":{
                        "source":'MOBILE',
                        "page":params.page,
                        "rows":params.rows,
                        "size":params.size,
                        "currentUserCode":util.encrypt(params.userName),
                        "companyName":params.companyName,
                        "companyCode":params.companyCode,
                        "gridName":params.gridName,
                        "title":params.title,
                        "policyStatue":params.policyStatue,
                        "startTime":params.startTime,
                        "endTime":params.endTime,
                    },
                "jsonName":'appDecision',
                "appDecision":{
                    "page":params.page,
                    "rows":params.rows,
                    "companyName":params.companyName,
                    "companyCode":params.companyCode,
                    "gridName":params.gridName,
                    "title":params.title,
                    "policyStatue":params.policyStatue,
                    "startTime":params.startTime,
                    "endTime":params.endTime,
                }    
            }
        }
    )
}

//获取思政纪实台账列表
export function getszjstaizhang(params){
    return request(
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usRecordFill$api$findAllUsRecordFill?source=MOBILE&page='
            +params.page+"&rows"+params.rows+"&size=10",
            contentType: 'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "currentUserCode":util.encrypt(params.userName),
                "versionName":"2.7.92",
                    "kv":{
                        "source":'MOBILE',
                        "page":params.page,
                        "rows":params.rows,
                        "size":params.size,
                        "currentUserCode":util.encrypt(params.userName),
                    },
                "jsonName":'appDecision',
                "appDecision":{
                    "companyName":params.companyName,
                    "companyCode":params.companyCode,
                    "configDeptName":params.configDeptName,
                    "talkTime":params.talkTime,
                    "startTime":params.startTime,
                    "endTime":params.endTime,
                    "page":params.page,
                    "rows":params.rows,
                }        
            }
        }
    )
}

//获取思政纪实台账列表的详情信息
export function getszjsDetail(params){
    return request(
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usRecordFill$api$recordDetail?source=MOBILE',
            contentType:'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "currentUserCode":util.encrypt(params.userName),
                "versionName":"2.7.92",
                "source":'MOBILE',
                "kv":{
                    "currentUserCode":util.encrypt(params.userName),
                    "source":'MOBILE',
                    "id":params.szjsdetailid,
                }
            }
        }
    )
}

//获取思政纪实配置列表
export function getszjssetList(params){
    return request(
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usRecordConfig$api$findAllInfo?source=MOBILE&page='
            +params.page+"&rows"+params.rows+"&size=10",
            contentType: 'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "currentUserCode":util.encrypt(params.userName),
                "versionName":"2.7.92",
                    "kv":{
                        "source":'MOBILE',
                        "page":params.page,
                        "rows":params.rows,
                        "size":params.size,
                        "currentUserCode":util.encrypt(params.userName),
                    }
            }
        }
    )
}


//保存思政纪实配置列表
export function saveSzjsFromDetail(params){
    console.log('name是'+params.userName)
    return request(
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usRecordConfig$api$insertUsRecordConfig?source=MOBILE',
            contentType: 'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "currentUserCode":util.encrypt(params.userName),
                "versionName":"2.7.92",
                    "kv":{
                        "source":'MOBILE',
                        "currentUserCode":util.encrypt(params.userName),
                    },
                "jsonName":'appDecision',
                "appDecision":params.fromdetaildata    
            }
        }
    )
}

//删除思政纪实配置数据
export function deleteSzjsFromDetail(params){
    console.log('name是'+params.userName)
    return request(
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usRecordConfig$api$deleteUsRecordConfig?source=MOBILE',
            contentType: 'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "currentUserCode":util.encrypt(params.userName),
                "versionName":"2.7.92",
                    "kv":{
                        "source":'MOBILE',
                        "currentUserCode":util.encrypt(params.userName),
                        "id":params.id
                    },
                "jsonName":"appDecision",
                "appDecision":{
                    "id":params.id
                }      
            }
        }
    )
}
//保存思政纪实上报内容
export function saveszjsDetail(params){
    return request(
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usRecordFill$api$insertUsRecordFill?source=MOBILE',
            contentType: 'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "currentUserCode":util.encrypt(params.userName),
                "versionName":"2.7.92",
                    "kv":{
                        "source":'MOBILE',
                        "currentUserCode":util.encrypt(params.userName),
                    },
                "jsonName":'appDecision',
                "appDecision":params.fromdetaildata    
            }
        }
    )
}


//获取问题上报工单详情
export function getWtsbDetail(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usProblemInfo$api$getFormDetail?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"djfupt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
                "kv":{
                    "source":'MOBILE',
                    "currentUserCode":util.encrypt(params.userName),
                    "processInstId":params.processInstId,
                    "workFlag":params.workFlag,
                    "location":params.location,
                    "pmInsId":params.pmInsId,
                }
        }
    })
}
//获取问题上报台账列表
export function getwtsbtaizhang(params){
    return request(
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usProblemInfo$api$queryAllUsCaseInfo?source=MOBILE&page='
            +params.page+"&rows"+params.rows+"&size=10",
            contentType: 'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "currentUserCode":util.encrypt(params.userName),
                "versionName":"2.7.92",
                    "kv":{
                        "source":'MOBILE',
                        "page":params.page,
                        "rows":params.rows,
                        "size":params.size,
                        "currentUserCode":util.encrypt(params.userName),
                    },
                "jsonName":'appDecision',
                "appDecision":{
                    "page":params.page,
                    "rows":params.rows,
                    "companyName":params.companyName,
                    "companyCode":params.companyCode,
                    "problemName":params.problemName,
                    "state":params.state,
                    "startTime":params.startTime,
                    "endTime":params.endTime,
                }    
            }
        }
    )
}
//获取经验推广工单详情
export function getJytgDetail(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usCaseInfo$api$getFormDetail?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"djfupt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
                "kv":{
                    "source":'MOBILE',
                    "currentUserCode":util.encrypt(params.userName),
                    "processInstId":params.processInstId,
                    "workFlag":params.workFlag,
                    "location":params.location,
                    "pmInsId":params.pmInsId,
                }
        }
    })
}

//获取经验推广台账列表
export function getjytgtaizhang(params){
    return request(
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usCaseInfo$api$findAllApplication?source=MOBILE&page='
            +params.page+"&rows"+params.rows+"&size=10",
            contentType: 'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "currentUserCode":util.encrypt(params.userName),
                "versionName":"2.7.92",
                "kv":{
                    "source":'MOBILE',
                    "page":params.page,
                    "rows":params.rows,
                    "size":params.size,
                    "currentUserCode":util.encrypt(params.userName),
                },
                "jsonName":'appDecision',
                "appDecision":{
                    "page":params.page,
                    "rows":params.rows,
                    "companyName":params.companyName,
                    "companyCode":params.companyCode,
                    "problemName":params.problemName,
                    "state":params.state,
                    "startTime":params.startTime,
                    "endTime":params.endTime,
                }    
            }
        }
    )
}

//获取单位列表数据
export function getOrgdata(params){
    return request(
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/queryDictValue$api$queryByType?source=MOBILE',
            contentType: 'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"djfupt",
                "currentUserCode":util.encrypt(params.userName),
                "versionName":"2.7.92",
                    "kv":{
                        "source":'MOBILE',
                        "dictType":'company',
                        "currentUserCode":util.encrypt(params.userName),
                    }
            }
        }
    )
}